<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="Totomo">
  <meta name="Keywords" content="password">
  <meta name="Description" content="check_password">
  <title>判断密码</title>
  <script type="text/javascript">
	function pw(){
		var count= [0,0,0,0,0];
		var pw1 = document.getElementById("pw").value;
		for (var i=0; i<pw1.length; i++)
		{
			var charc = pw1.charCodeAt(i);
			if (48<=charc&&charc<=57)
			{
				count[0]=1;
			}else if ((33<=charc&&charc<=47)||(58<=charc&&charc<=64))
			{
				count[1]=1;
			}else if (65<=charc&&charc<=90)
			{
				count[2]=1;
			}else if (97<=charc&&charc<=122)
			{
				count[3]=1;
			}else
			{
				count[4]=1;
			}
			
		}

		var cc = 0;
		for (var i=0;i<count.length;i++)
		{
			if (count[4]==1){
				cc=5;
				break;
			}else if(count[i]==1){
				cc++;
			}
		}
		switch (cc)
		{
			case 0: document.getElementById("checkpw").innerHTML="请输入密码";break;
			case 1: document.getElementById("checkpw").innerHTML="您的密码强度为 弱";break;
			case 2: document.getElementById("checkpw").innerHTML="您的密码强度为 中";break;
			case 3: document.getElementById("checkpw").innerHTML="您的密码强度为 强";break;
			case 4: document.getElementById("checkpw").innerHTML="您的密码强度为 强";break;
			case 5: document.getElementById("checkpw").innerHTML="含有非法字符！";break;
		}
	}
  </script>
 </head>
 <body>
  1、输入密码，判断密码的强弱<br/>
  <input type="text" onkeyup="pw()" id="pw"/><br/>
  <span id="checkpw"></span><br/>
 </body>
</html>
